import org.dom4j.Document;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.dom4j.io.XMLWriter;

import javax.swing.text.ElementIterator;
import java.io.File;
import java.io.FileInputStream;
import java.util.List;
import java.util.Properties;

public class Main {
    public static void main(String[] args) throws Exception{
        //配置文件properties读写
        Properties prop = new Properties();
        prop.load(new FileInputStream("resources/test.properties"));
        System.out.println( prop.getProperty("url"));

        //xml读写
        SAXReader reader = new SAXReader();
        Document doc =  reader.read(new File("resources/demo.xml"));
        Element eml =  doc.getRootElement();//获取根节点
        System.out.println( eml.attribute("color").getValue());
//        System.out.println(eml.getText());
//        System.out.println(eml.getName());
//        System.out.println(eml.getQualifiedName());
        List<Element> list =  eml.elements("student");
        for(Element em : list){
            System.out.println( em.element("name").getText());
            System.out.println( em.element("age").getText());
        }

        //XPath 路径标识符
        Document doc1 = DocumentHelper.createDocument();
        XMLWriter writer = new XMLWriter();

    }
}
